<script>
import ZFilterInput from "./ZFilterInput";
import ZfilterSelect from "./ZfilterSelect";
import ZFilterDateTime from "./ZFilterDateTime";
import ZFilterNumberInput from "./ZFilterNumberInput";

function getComponent(input) {
  switch (input.type.toLowerCase()) {
    case "text":
    case "textarea":
      return ZFilterInput;
    case "number":
      return ZFilterNumberInput;
    case "select":
      return ZfilterSelect;
    case "datetime":
    case "date":
      return ZFilterDateTime;
  }
}

export default {
  inheritAttrs: false,
  props: {
    input: {
      type: Object,
      default() {
        return {};
      },
    },
  },
  render(h) {
    const component = getComponent(this.input);
    return h(component, {
      attrs: { input: this.input },
      on: this.$listeners,
    });
  },
};
</script>
